package com.yingsheng.bi.hks.service.home;

import com.yingsheng.bi.hks.dto.home.HomeResourceSearchReq;
import com.yingsheng.bi.hks.dto.home.HomeResourceSearchRes;
import com.yingsheng.bi.hks.feign.client.HomeFeignClient;
import com.yingsheng.bi.hks.repository.dao.po.Resource;
import com.yingsheng.bi.hks.repository.dao.service.ResourceDaoService;
import com.yingsheng.bi.hks.template.annotation.Template;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class HomeService implements HomeFeignClient {


    @Autowired
    private ResourceDaoService resourceDaoService;


    @Template
    @Override
    public HomeResourceSearchRes homeResourceSearch(HomeResourceSearchReq req) {
        List<Resource> list = resourceDaoService.qryForHome(req);
        HomeResourceSearchRes res = new HomeResourceSearchRes();
        if (list.isEmpty()){
            return res;
        }
        res.setResourceUrl(list.get(0).getPath());
        return res;
    }
}
